package com.module.app.widget.dialog;

import android.content.Context;

import com.module.frame.dialog.ILoadingDialogImpl;

/**
 * @author bsnl_yanxuwen
 * @date 2021/1/21 11:33
 * Description :
 * 代理类，，用于接口请求，跟界面加载
 * 加载弹窗
 */
public class LoadingDialogImpl implements ILoadingDialogImpl {

    public LoadingDialog loadingDialog = null;

    /**
     * 创建LoadingDialog
     */
    public void createLoadingDialog(Context context) {
        if (loadingDialog == null) {
            loadingDialog = new LoadingDialog(context);
            loadingDialog.setCancelable(true);
            loadingDialog.setCanceledOnTouchOutside(false);
        }
    }

    @Override
    public void show(Context context) {
        createLoadingDialog(context);
        if (!loadingDialog.isShowing()) {
            loadingDialog.show();
        }
    }

    @Override
    public void hide() {
        if (loadingDialog != null && loadingDialog.isShowing()) {
            loadingDialog.dismiss();
        }
    }

    @Override
    public void destroy() {
        hide();
        loadingDialog = null;
    }


}
